package priv.jesse.mall.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import priv.jesse.mall.entity.Classification;
import priv.jesse.mall.entity.Product;

import java.util.List;

public interface ClassificationDao extends JpaRepository<Classification, Integer> {
    List<Classification> findByType(int type);

    Page<Classification> findByType(int type, Pageable pageable);

    List<Classification> findByParentId(int cid);

    @Query(value = "SELECT * FROM  classification where type=1 ORDER BY paihang ASC limit 8",nativeQuery = true)
    List<Classification> findLocal();

    @Query(value = "SELECT * FROM  classification where type=2 ORDER BY paihang ASC ",nativeQuery = true)
    List<Classification> findTwoType();
}
